<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .div1{
            width:400px;
            height: 400px;
            border:1px solid black;
        }
        .div2{
            width:300px;
            height: 300px;
            border:1px solid black;
        }
        .div3{
            width:200px;
            height: 200px;
            border:1px solid black;
        }
        .div4{
            width:100px;
            height: 100px;
            border:1px solid black;
        }
    </style>
    <script>
        function showIt(name,e){
            console.log(name);
            if(e&&name=="div2"){
                e.stopPropagation();
            }
        }
    </script>
</head>
<body>
    <div class="div1"  onclick="showIt('div1')">
        div1
        <div class="div2"  onclick="showIt('div2',event)">
            div2
            <div class="div3" onclick="showIt('div3')">
                div3
                <div class="div4"  onclick="showIt('div4')">
                    div4
                </div>
            </div>
        </div>
    </div>
    <hr>
    <script>
        window.onload=function(){
            div1.addEventListener("click",function(){
                console.log("div1");
            },true);
            div2.addEventListener("click",function(){
                console.log("div2");
            },true);
            div3.addEventListener("click",function(event){
                console.log("div3");
                event.stopPropagation();
            },true);
            div4.addEventListener("click",function(){
                console.log("div4");
            },true);
        }
    </script>
    <div class="div1" id="div1" >
        div1
        <div class="div2" id="div2" >
            div2
            <div class="div3" id="div3" >
                div3
                <div class="div4" id="div4" >
                    div4
                </div>
            </div>
        </div>
    </div>

</body>
</html>